#pragma once

#include <QGraphicsScene>
using namespace std;
#include "sim.h"
class Node;
class Pipe;
class PipeLine;
class sim;

class SceneView : public QGraphicsScene
{
	Q_OBJECT

public:
	SceneView(sim *_main);
	~SceneView();

	Node* addNode(QPointF pos, QString name = "", bool visibleTitle = true);
	PipeLine* addPipeLine(Node *sourceNode, Node *destNode, QString coordinates = "", QString name = "", bool visibleTitle = true);
	vector<Node*> node_list;
	vector<PipeLine*> pipeline_list;
	sim *main;
private:
	int virtual_item_type;
	bool allow_add_path;
	PipeLine *virtual_pipeline;
	Node *virtual_node; 
	void log(const QString &text){main->log(text);}

	Node* checkAcceptedNode(const QPointF &pos);
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
	void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
	void keyPressEvent(QKeyEvent *event);
	void keyReleaseEvent(QKeyEvent *event);
	void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
	void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
	void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
	void dropEvent(QGraphicsSceneDragDropEvent *event);
	
public slots:
	void dropItem(int index){virtual_item_type = index;}
	void CopyItem();
	void PasteItem();
	void CutItem();
	void DeleteItem();
	void beginDrawPipeline();
	void endDrawPipeline();
signals:
	
};
